Skip to content

fix(seo): cache sitemap so Google can fetch it#34

Merged
oratis merged 1 commit into
mainfrom
claude/sitemap-cache
Jun 27, 2026
Merged

fix(seo): cache sitemap so Google can fetch it#34
oratis merged 1 commit into
mainfrom
claude/sitemap-cache

Conversation

@oratis

@oratis oratis commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Problem

GSC reports "Couldn't fetch" (无法抓取) with 0 URLs discovered for https://takoapi.com/sitemap.xml.

Root cause: sitemap.ts is force-dynamic. With ~6,777 URLs each carrying 15-locale hreflang alternates, it regenerates against the DB on every request — measured at ~13s and ~12MB. Google's sitemap fetcher times out on that. (Size is within Google's 50MB/50k-URL limits; generation time is the killer.)

Fix

Switch from force-dynamic to ISR (export const revalidate = 3600): serve a cached copy and regenerate at most hourly in the background (stale-while-revalidate), so crawlers always get a fast response.

The existing try/catch already tolerates the DB-less Docker build, so the build-time render falls back to the static routes; the first request after deploy fills in agents/skills and caches the full sitemap. Catalog changes propagate within the hour — fine, since crawlers hit this infrequently.

After deploy

Re-submit / let GSC re-fetch sitemap.xml; the response is now fast and cacheable.

🤖 Generated with Claude Code

The sitemap was force-dynamic: with ~6.8k URLs × 15-locale hreflang it
regenerates in ~13s and serializes to ~12MB on every request, so Google
Search Console's fetcher times out ("Couldn't fetch", 0 URLs discovered).

Switch to ISR (revalidate = 3600): serve a cached copy and regenerate at
most hourly in the background, so crawlers always get a fast response. The
existing try/catch already tolerates the DB-less Docker build, which now
renders the static-routes fallback at build time; the first request after
deploy fills in agents/skills and caches the full sitemap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@oratis oratis merged commit 9fb8cab into main Jun 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant